package com.chixing.controller;


import com.chixing.service.IProductService;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-09-22
 */
@CrossOrigin
@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IProductService productService;
    @GetMapping
    public Result gateAllPage(@RequestParam(value = "pageNumber" ,required = false) Integer pageNumber,
                              @RequestParam(value = "proName",required = false)String proName,
                              @RequestParam(value = "MinPrice",required = false)Float MinPrice,
                              @RequestParam(value = "MaxPrice",required = false)Float MaxPrice){

       return productService.getAllPage(pageNumber,proName,MinPrice,MaxPrice);
    }

    @GetMapping("{id}")
    public Result getProductDetail(@PathVariable("id") Integer id){
        return productService.getByIdDetail(id);
    }

}
